/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Dec 22, 2009 11:38:25 PM $
 *
 * Author: Eric Yang
 * Date  : Dec 22, 2009 11:38:25 PM
 *
 */
package com.gooex.web.action.gbuy.order;

import com.gooex.domain.base.Order;
import com.gooex.service.base.IOrderManager;
import com.gooex.web.action.BaseAnonymousAction;


/**
 * @author Eric Yang
 * @version 1.0
 */
public class BaseOrderAction extends BaseAnonymousAction {

	protected IOrderManager orderManager;

	public final boolean canJoinAsCustomer(String orderId) {
		return orderManager.canJoinAsCustomer(orderId, getCurrentUser().getId());
	}

	public final boolean canJoinAsVendor(String orderId) {
		return orderManager.canJoinAsVendor(orderId, getCurrentUser().getId());
	}

	public final boolean canChangeOrderStatus(Order order) {
		if (getCurrentUser() == null || order == null
				|| !getCurrentUser().getId().equals(order.getResponsibleUser().getId())
				|| orderManager.canChangeOrderStatus(order))
			return false;
		return true;

	}

	public final boolean isOrderCustomer(Order order) {
		return orderManager.isOrderCustomer(order, getCurrentUser());
	}

	public final boolean isOrderVendor(Order order) {
		return orderManager.isOrderVendor(order, getCurrentUser());
	}

	public final void setOrderManager(IOrderManager orderManager) {
		this.orderManager = orderManager;
	}
}
